package hotgammon.domain;

import minidraw.framework.DrawingEditor;
import minidraw.standard.MiniDrawApplication;
import hotgammon.view.BackgammonDrawing;
import hotgammon.view.BackgammonFactory;
import hotgammon.view.BackgammonUserInterface;

public class GameUserInterface implements BackgammonUserInterface {

	private DrawingEditor editor;
	private Game game;

	public GameUserInterface( String applTitle, GameFactory gf ) {
		BackgammonFactory factory = new BackgammonFactory();

		editor =
			new MiniDrawApplication( applTitle, factory );
		game = new GameImp(gf);

		// we need to set the dependency between game and
		// the minidraw drawing instance.
		BackgammonDrawing bd = (BackgammonDrawing) factory.drawing;
		bd.setObjectServer( this );

		// and register the drawing as listener on game events
		game.addGameListener( bd );
	}

	public Game getGame() { return game; }

	public DrawingEditor getEditor() { return editor; }
}
